﻿namespace Yom.Common
{
    using System;
    using System.Web;

    public class UrlRewrite : IHttpModule
    {
        public void Init(HttpApplication objApp)
        {
            objApp.BeginRequest += new EventHandler(Rewrite_BeginRequest);
        }

        private void Rewrite_BeginRequest(object sender, EventArgs e)
        {
            HttpApplication application = sender as HttpApplication;
            string url = SiteLoad.GetUrl(application.Request.Path);

            if (!string.IsNullOrEmpty(url))
                application.Context.RewritePath(url);
        }

        void IHttpModule.Dispose()
        {
        }
    }
}